var map, swissgeoMKey;
 
var topoch = new google.maps.ImageMapType({
	getTileUrl: function(ll, z) {
		mcn=parseInt((Math.random()*10000)%4)+1;
		wmscUrl="http://mc"+mcn+".swissgeo.ch/wms-c/"+swissgeoMKey.key+"/topomaps/1.0.0/ch/" + z + "/" + ll.x + "/" + ll.y + ".png";
		return wmscUrl;
	},
	tileSize: new google.maps.Size(256, 256),
	isPng: true,
	minZoom: 9,
	maxZoom: 15,
	opacity:1,
	name: "Swisstopo",
	alt: "topo ch"
});
 
var gimapssat = new google.maps.ImageMapType({
	getTileUrl: function(ll, z) {
		mcn=parseInt((Math.random()*10000)%4)+1;
		wmscUrl="http://mc"+mcn+".swissgeo.ch/wms-c/"+swissgeoMKey.key+"/gimaps/1.0.0/satellite/" + z + "/" + ll.x + "/" + ll.y + ".png";
		return wmscUrl;
	},
	tileSize: new google.maps.Size(256, 256),
	isPng: true,
	maxZoom: 18,
	opacity:0.8,
	name: "Satellite",
	alt: "geomatic Maps sat"
});
 
 
//function initialize(id, kml) {
function initialize(kml) {
	var latlng = new google.maps.LatLng(46.8, 8.2);
    
	var myOptions = {
		zoom: 8,
		center: latlng,
		mapTypeId: 'topoch'
	}
 
	map = new google.maps.Map(document.getElementById("map_canvas_fiche"), myOptions);
	swissgeoMKey= new swissgeoMKey();
		map.mapTypes.set('gisat', gimapssat);
		map.mapTypes.set('topoch', topoch);
 
		map.setMapTypeId('topoch');
		var optionsUpdate = {
			mapTypeControlOptions: {
				mapTypeIds: ['topoch','gisat']
			}
		};
		map.setOptions(optionsUpdate);
 
	var kmlLayer = new google.maps.KmlLayer(kml);
	kmlLayer.setMap(map);
}